<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <title>骡窝日报详情</title>
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <link rel="stylesheet" href="/js/bootstrap/css/bootstrap.min.css">
    <script src="/js/jquery/jquery.min.js"></script>
    <script src="/js/bootstrap/js/bootstrap.min.js"></script>
    <link rel="stylesheet" href="/css/font/css/font-awesome.min.css">
    <link rel="stylesheet" href="/css/reset.css">
    <link rel="stylesheet" href="/css/newsContent.css">
    <script src="/js/plugins/jrender/jrender.min.js"></script>
    <script src="/js/common.js"></script>

</head>
<script>
    $(function () {
        var params = getParams();
        var a;
        $.get("/news/" + params.id, function (data) {
            // console.log(data);
            a = data.type;
            $("#content").renderValues(data);
            //查询相同类型的资讯
            $.get("/news", {type: a,pageSize:5}, function (data) {
                console.log(data);
                //如果同类型不够5条则查询最新发布的5条
                if ((data.list.length)<5) {
                    $.get("/news", { pageSize: 5}, function (data) {
                        console.log(data);
                        $(".referenceNews").renderValues(data,{
                            setHref: function (item, value) {
                                $(item).attr("href", $(item).attr("href") + value);
                            }
                        });
                        $(".carousel-item:first").addClass("active");
                    });
                }else {
                    $(".referenceNews").renderValues(data,{
                        setHref: function (item, value) {
                            $(item).attr("href", $(item).attr("href") + value);
                        }
                    });
                    $(".carousel-item:first").addClass("active");
                }
            });
        });

    });
</script>
<body>
<div class="newsDetail">
    <div id="content">
        <a href="javascript:history.go(-1);" style="position: absolute;top: 10px;left: 22px;">
            <span><i class="fa fa-chevron-left fa-2x" style="color: white;"></i></span>
        </a>
        <img render-src="coverUrl">

        <div class="container">
            <div class="row typeRow">
                <div class="col-4">
                    <span class="type" render-html="typeDisplay">美图美文</span>
                </div>
                <div class="col-2">
                </div>
                <div class="col-2">
                    <span>By</span>
                </div>
                <div class="col-4">
                    <span class="type" render-html="user.nickName">骡窝官方</span>
                </div>
            </div>
            <div class="detail">
                <h2 class="title" render-html="title">名人眼中旅行的意义</h2>
                <div class="content" render-html="newsContent.content">
                </div>
            </div>
        </div>
    </div>
    <hr>
        <div class="container">
            <h6 class="module-title">相关推荐</h6>
            <div id="carouselExampleControls" class="carousel slide" data-ride="carousel">
                <div class="referenceNews">
                    <div class="carousel-inner " render-loop="list">
                        <div class="carousel-item ">
                            <a href="newsContent.html?id=" render-fun="setHref" render-key="list.id" >
                                <img class="d-block w-80" render-src="list.coverUrl" width="100%" height="100px">
                            </a>
                            <div class="recommend-author">
                                <a href="newsContent.html?id=" render-fun="setHref" render-key="list.id">
                                    <span class="recommend" render-html="list.title"></span></a>
                            </div>
                            <div>
                                <span render-html="list.release_time"></span>
                            </div>
                        </div>
                    </div>
                </div>
            <a class="carousel-control-prev" href="#carouselExampleControls" role="button" data-slide="prev">
                <span class="carousel-control-prev-icon" aria-hidden="true"></span>
                <span class="sr-only"></span>
            </a>
            <a class="carousel-control-next" href="#carouselExampleControls" role="button" data-slide="next">
                <span class="carousel-control-next-icon" aria-hidden="true"></span>
                <span class="sr-only"></span>
            </a>
            </div>
            <hr>
    </div>

    <div class="container">
        <h6 class="module-title">用户评论</h6>

    </div>

</div>
</body>
</html>